import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
// 解决导航栏或者底部导航tabBar中的vue-router在3.0版本以上频繁点击菜单报错的问题。
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)
const routes = [

  {
    path: '/',
    name: 'Manager',
    component: () => import('../views/Manager.vue'),
    redirect: '/home',  // 重定向到主页
    children: [
      {path: '/403', name: 'Auth',meta:{name:'无权限'}, component: () => import('../views/manager/Auth.vue')},
      { path: 'home', name: 'Home',meta:{name:'系统首页'}, component: () => import('../views/manager/Home.vue') },
      { path: 'person', name: 'Person',meta:{name:'个人信息'},component: () => import('../views/manager/Person.vue') },
      { path: 'password', name: 'Password',meta:{name:'修改密码'},component: () => import('../views/manager/Password.vue') },
      {path: 'users', name: 'Users',meta:{name:'用户信息'}, component: () => import('../views/manager/Users.vue')},
      {path: 'classes', name: 'Classes',meta:{name:'班级信息'}, component: () => import('../views/manager/Classes.vue')},
      {path:'permissions',name:'Permissions',meta:{name:'权限信息'},component:()=>import('../views/manager/Permissions.vue')},
      {path:'files',name:'Files',meta:{name:'文件信息'},component:()=>import('../views/manager/Files.vue')},
      {path:'folders',name:'Folders',meta:{name:'文件夹信息'},component:()=>import('../views/manager/Folders.vue')},
      {path:'test',name:'Test',meta:{name:'测试'},component:()=>import('../views/manager/Test.vue')},
      {path:'test02',name:'Test02',meta:{name:'测试2'},component:()=>import('../views/manager/Test02.vue')},
      {path:'test03/:folderId',name:'Test03',meta:{name:'测试3'},component:()=>import('../views/manager/Test03.vue')},

    ]
  },
  { path: '/login', name: 'Login', meta: { name: '登录' }, component: () => import('../views/Login.vue') },
  { path: '/register', name: 'Register', meta: { name: '注册' }, component: () => import('../views/Register.vue') },
  { path: '/*', name: 'Page404', meta: { name: '无法访问' }, component: () => import('../views/404.vue') },
];

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router